package com.lucas.servlet.chapter3_1.dao;


import com.lucas.servlet.chapter3_1.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;


@Repository
public class UserDao {
    @Autowired
    static JdbcTemplate jdbcTemplate;
    public static User getUserByName(String userName){
        String sql="select * from users where username = ?";
        return jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<User>(User.class),userName);
    }
}
